package com.bianhua.front;

import com.bianhua.entity.Company;
import com.bianhua.entity.Post;
import com.bianhua.service.CompanyService;
import com.bianhua.service.PostService;
import com.bianhua.utils.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/f/company/")
public class CompanyFront {

    @Autowired
    PostService postService;
    @Autowired
    CompanyService companyService;

    @GetMapping("info")
    public Result detail(Integer id){
        Company company = companyService.detail(id);
        Post param = new Post();
        param.setCompanyId(company.getId());
        PageInfo<Post> pageInfo = postService.query(param);
        company.setList(pageInfo.getList());
        return Result.ok(company);
    }

    @GetMapping("query")
    public Map<String, Object> company(){
        Company company = new Company();
        company.setPage(0);
        company.setLimit(12);
        PageInfo<Company> pageInfo = companyService.query(company);
        return Result.ok(pageInfo);
    }


}
